package cn.iocoder.yudao.module.alipay.controller.app.surname;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.alipay.controller.admin.sensitivenems.vo.SensitiveNemsRespVO;
import cn.iocoder.yudao.module.alipay.controller.admin.surname.vo.*;
import cn.iocoder.yudao.module.alipay.convert.sensitivenems.SensitiveNemsConvert;
import cn.iocoder.yudao.module.alipay.convert.surname.SurnameConvert;
import cn.iocoder.yudao.module.alipay.dal.dataobject.sensitivenems.SensitiveNemsDO;
import cn.iocoder.yudao.module.alipay.dal.dataobject.surname.SurnameDO;
import cn.iocoder.yudao.module.alipay.service.surname.SurnameService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;

@Tag(name = "管理后台 - 姓氏")
@RestController
@RequestMapping("/alipay/surname")
@Validated
public class SurnameApiController {

    @Resource
    private SurnameService surnameService;

    @GetMapping("/getByName")
    @Operation(summary = "获得姓氏")
    @Parameter(name = "name", description = "名称", required = true, example = "1024")
    public CommonResult<SurnameRespVO> getByName(@RequestParam("name") String name) {
        SurnameDO surname = surnameService.getByName(name);
        return success(SurnameConvert.INSTANCE.convert(surname));
    }

    @GetMapping("/validSelectBySensitiveTxt")
    @Operation(summary = "检测敏感词")
    @Parameter(name = "sensitiveTxt", description = "名称", required = true, example = "1024")
    public CommonResult<SensitiveNemsRespVO> validSelectBySensitiveTxt(@RequestParam("sensitiveTxt") String sensitiveTxt) {
        SensitiveNemsDO sensitiveNemsDO= surnameService.validCellValue(sensitiveTxt);
        return success(SensitiveNemsConvert.INSTANCE.convert(sensitiveNemsDO));
    }



}
